package com.lightsh.widget.testactivity;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.lightsh.scrollview.HScrollViewGroup;
import com.lightsh.widget.R;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class HScrollViewActivity extends Activity implements OnClickListener{
	
	
	private HScrollViewGroup mScrollContent;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        
        setContentView(R.layout.hscrollview_layout);
        
        mScrollContent = (HScrollViewGroup) findViewById(R.id.listContent);
        
        LinearLayout layout = new LinearLayout(this);
        layout.setBackgroundColor(Color.GRAY);
        mScrollContent.addView(layout);
        
        layout = new LinearLayout(this);
        layout.setBackgroundColor(Color.RED);
        mScrollContent.addView(layout);
        
        
        layout = new LinearLayout(this);
        layout.setBackgroundColor(Color.BLUE);
        mScrollContent.addView(layout);
        
        ScrollView sv = new ScrollView(this);
        sv.setLayoutParams(new LayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)));
        
        
        
        TextView text = new TextView(this);        
        StringBuffer str = new StringBuffer();
        for(int i = 0; i < 1000 ; ++i){
        	str.append("Hello Scroller!    ");
        }
        text.setText(str);
        sv.addView(text);        
        layout = new LinearLayout(this);
        layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        layout.addView(sv);
        mScrollContent.addView(layout);
        
        
        ListView listView = new ListView(this);
        
        ArrayList<String> dataList = new ArrayList<String>();
        for(int i = 0; i < 100; ++i){
        	dataList.add("Hello Scroller!    ");
        }
        
        listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, dataList));
        mScrollContent.addView(listView);
        
        findViewById(R.id.btn1).setOnClickListener(this);
        findViewById(R.id.btn2).setOnClickListener(this);
        findViewById(R.id.btn3).setOnClickListener(this);
        findViewById(R.id.btn4).setOnClickListener(this);
        findViewById(R.id.btn5).setOnClickListener(this);
        
        
        
    }

	public void onClick(View v) {
		switch(v.getId()){
		case R.id.btn1:{
			mScrollContent.snapToScreen(0);
		}
			break;
		case R.id.btn2:{
			mScrollContent.snapToScreen(1);
		}
			break;
		case R.id.btn3:{
			mScrollContent.snapToScreen(2);
		}
			break;
		case R.id.btn4:{
			mScrollContent.snapToScreen(3);
		}
			break;
		case R.id.btn5:{
			mScrollContent.snapToScreen(4);
		}
			break;
		}
		
	}
	
}
